#include <iostream>
#include <algorithm>
#define MAXN 100
using namespace std;

int N, edge[MAXN];
void solve();

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> edge[i];
    solve();
    return 0;
}

/*  直接排序, 然后从大到小取值就行了 */
void solve() {
    sort(edge, edge + N);
    for (int i = N - 1; i >= 2; i--) {
        if (edge[i - 1] + edge[i - 2] >= edge[i])
            { cout << edge[i - 1] + edge[i - 2] + edge[i - 3] << endl; return;}
    }
}